'use strict';

// app/controller/home.js
const Controller = require('egg').Controller;

class PersonController extends Controller {
    // 查询数据（查询按钮查询数据）
    async index() {
        let { ctx, service } = this;
        let did = ctx.request.url.split('=')[1];
        console.log(did, 55555555555555555555, ctx);
        try {
            let result = await service.index.findOne(did);
            let { rows, count } = result;
            ctx.body = {
                code: '200',
                msg: '数据获取成功',
                data: rows,
                count: count
            }
        } catch (error) {
            console.log(error);
            ctx.body = {
                code: '500',
                msg: '服务器异常'
            }
            ctx.status = 500;
        }
    }

}

module.exports = PersonController;